import * as layoutFetch from '../api/apiLayout'
import {findInArray, getHistory, getState, setState, setStateReducer} from "../util/uitls";
import {effects} from 'dva-no-router/saga'

/**
 * 界面layout的model
 * @author 刘明泰 <18819448261>
 * @example <Loading isLoading={true} timedOut={100} />
 * @desc
 *  ** initState **
 ```
 isMobile: false,//判断是不是手机端
 left_menu_collapsed: false,//菜单缩小
 menuArray: [],//菜单列表
 documentHeight: null,//文档高度
 ```
 * */
const INIT_STATE = {collectStore: []}
const Map = require('lodash.map')
const model_layout = {
    namespace: 'layout',
    state: INIT_STATE,
    reducers: {
        setState: setStateReducer
    },
    effects: {
        * setSelectMenuKeys({payload: {pathname}}, {call, put}) {
            yield setState({
                selectMenuKeys: pathname
            })('layout')
        },
        * setUserCollectStore({payload: {collectStore}}, {call, put}) {
            yield setState({
                collectStore: null
            })('layout')
            yield setState({
                collectStore: collectStore
            })('layout')
        }
    },
    subscriptions: {
        setup({dispatch, history}) {
        },
    },
};

export default model_layout
